package totiao;

import java.util.Scanner;

/**
 * Created by lxy_920912 on 30/03/2017.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int[] arr = new int[num];
        arr[0] = scanner.nextInt();
        int start = 0;
        int end = 0;
        int preStart = 0;
        int preEnd = 0;
        int flag = 0;
        for(int i = 1;i < num;i++){
            arr[i] = scanner.nextInt();
            if(flag == 0){
                if(arr[i] > arr[i-1]){
                    continue;
                }else{
                    flag = 1;
                    continue;
                }
            }else{
                if(arr[i] < arr[i-1]){
                    continue;
                }else{
                    flag = 0;
                    end = i-1;
                    if((end -start) > (preEnd-preStart)){
                        preStart = start;
                        preEnd = end;
                    }
                    start = i-1;
                    continue;
                }

            }
        }
        if(flag == 1){
            end = num-1;
        }
        if((end -start) > (preEnd-preStart)){
            preStart = start;
            preEnd = end;
        }

        if((preStart == preEnd)||(preStart == 0 && preEnd == 0)){
            System.out.println("-1 -1");
        }
        System.out.println(preStart+" "+preEnd);
    }
}
